<%@page import="com.netistate.pojo.TechNote"%>
<%@page import="com.netistate.pojo.Sale"%>
<%@page import="com.netistate.pojo.Project"%>
<%@page import="java.text.SimpleDateFormat"%>
<%@page import="com.netistate.pojo.User"%>
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <title>项目页面</title>
    <link rel="stylesheet" type="text/css" href="${pageContext.request.contextPath}/css/default.css" />
    <script type="text/javascript"  src="${pageContext.request.contextPath}/js/common.js"></script>
    <script type="text/javascript"  src="${pageContext.request.contextPath}/js/jquery.js"></script>
    <script type="text/javascript"  src="${pageContext.request.contextPath}/js/table.js"></script>
    <script type="text/javascript"  src="${pageContext.request.contextPath}/plugin/msgbox/msgbox.js"></script>
    <script type="text/javascript"  src="${pageContext.request.contextPath}/jsp/project/project.js"></script>
    <script type="text/javascript"  src="${pageContext.request.contextPath}/plugin/calendar/Calendar.js"></script>
    <style type="text/css">
		.overTd {table-layout:fixed}
		.overTd td{text-overflow:ellipsis;overflow:hidden;white-space:nowrap;padding:0px}
    </style>
  </head>
  <body>
   <% String id = (String)request.getSession().getAttribute("projectid");
   	  Project p = (Project)request.getSession().getAttribute("selectProject");
   %>
   		<div id="xtab">
			<a id="rightDiv0_tab" href="#" class='homelink ' onclick="lookSale(<%=id%>)"><span style="cursor:pointer;">服务记录表</span></a>
			<a id="rightDiv1_tab" href="#" class='homelink curren' onclick=""><span style="cursor: pointer;">技术备忘录</span></a>
			<a id="rightDiv1_tab" href="#" class='homelink' onclick="lookClient(<%=id%>)"><span style="cursor: pointer;">客户信息表</span></a>
			<a id="rightDiv1_tab" href="#" class='homelink' onclick="lookDoc(<%=id%>)"><span style="cursor: pointer;">文档列表</span></a>
		</div>
   
   		<div class="toolbar" >
   			<a href="#" class='buttonlink txbtip' style="font-size:14pt;font-family:微软雅黑;display:inline;color:red" title='当前项目'>当前位置：<%=p.getProjectName() %>→技术备忘录</a>
   				<img width='16' height='16' src='${pageContext.request.contextPath}/images/common/elbow-line.gif'/>
		    <a href="#" id="queryProjectButton" title='技术备忘录查询' class='buttonlink txbtip' onclick="notHiddenDiv()" ><img width='16' height='16' src='${pageContext.request.contextPath}/images/common/flag_green.png'/>技术备忘录查询</a>
		    	<img width='16' height='16' src='${pageContext.request.contextPath}/images/common/elbow-line.gif'/><img width='16' height='16' src='${pageContext.request.contextPath}/images/common/elbow-line.gif'/>
		    <a href="#" class='buttonlink txbtip' title='添加技术备忘录' onclick="addTechNote(<%=id%>)"><img width='16' height='16' src='${pageContext.request.contextPath}/images/common/plus_orange.png'/>添加技术备忘录</a>
		    	<img width='16' height='16' src='${pageContext.request.contextPath}/images/common/elbow-line.gif'/><img width='16' height='16' src='${pageContext.request.contextPath}/images/common/elbow-line.gif'/>
		    <%-- <div style="float:right">  
		    	<span id="test" value="sssss"></span>
			    <a id="selectTechNote" href="#" class='buttonlink txbtip' title='项目服务表' onclick="lookSale(<%=id%>)"><img width='16' height='16' src='${pageContext.request.contextPath}/images/common/search.png'/>项目服务表</a>
	       		<a href="#" class='buttonlink txbtip' title='客户信息表' onclick="lookClient(<%=id%>)"><img width='16' height='16' src='${pageContext.request.contextPath}/images/common/safari.png'/>客户信息表</a>
	       		<a href="#" class='' title='' onclick="">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</a>
       		</div>   --%>
		</div>
		
		<div id="projectService" name="query_techNote" class="" style="display:block;background-color:#D5E2F2;line-height:55px;font-size:12px">
		    <form id="queryProjectTechNoteByCondition" name="projectQuery_condition" action="query_project_techNote_by_Condition.action" method="post" >
		        <table>
		           <tr>
	                	
		                <%-- <td>
		                	<input type="hidden" name="id" value="<%=id%>"/>
		                    <select id="state" name="state">
		                       <%String queryState = (String)request.getAttribute("queryProjectTechNoteState");
		                        if(queryState == null){%>
								   <option value="新增问题">新增问题</option>
								   <option value="未安排计划">未安排计划</option>
								   <option value="开发完成未上线">开发完成未上线</option>
								   <option value="开发完成已经上线">开发完成已经上线</option>
								   <option value="已经完成">已经完成</option>
								   <option value="取消跟踪">取消跟踪</option>
		                      <%}else{%>
		                      		<option value="<%=queryState %>"><%=queryState %></option>
		                      <%	if(!"所有".equals(queryState)){%>
		                      		<option value="所有">所有</option>
		                      <%	}
		                            if(!"新增问题".equals(queryState)){%>
		                            <option value="新增问题">新增问题</option>
		                      <%	}
		                            if(!"未安排计划".equals(queryState)){%>
	                                <option value="未安排计划">未安排计划</option><%
		                            }
		                            if(!"开发完成未上线".equals(queryState)){%>
	                                <option value="开发完成未上线">开发完成未上线</option><%
		                            }
		                            if(!"开发完成已经上线".equals(queryState)){%>
	                                <option value="开发完成已经上线">开发完成已经上线</option><%
		                            }
		                            if(!"已经完成".equals(queryState)){%>
	                                <option value="已经完成">已经完成</option><%
		                            }
		                            if(!"取消跟踪".equals(queryState)){%>
	                                <option value="取消跟踪">取消跟踪</option><%
		                            }
		                        }%>
		                    </select>
		                </td> --%>
		                <td class="td_title" title="级别"> 级别：</td>
		                <td class="td_title">
		                    <select id="level" name="level" style="width:100px;">
								<%String queryLevel = (String)request.getAttribute("queryProjectTechNoteLevel");
		                        if(queryLevel == null){%>
		                           	 <option title="所有" value="所有">所有</option>
									 <option title="紧急且重要" value="紧急且重要">紧急且重要</option>
									 <option title="紧急" value="紧急">紧急</option>
									 <option title="重要" value="重要">重要</option>
									 <option title="普通" value="普通">普通</option>
		                      <%}else{%>
		                      		<option value="<%=queryLevel %>"><%=queryLevel %></option>
		                      <%	if(!"所有".equals(queryLevel)){%>
		                      		<option value="所有">所有</option>
		                      <%	}
		                            if(!"紧急且重要".equals(queryLevel)){%>
		                            <option value="紧急且重要">紧急且重要</option>
		                      <%	}
		                            if(!"紧急".equals(queryLevel)){%>
	                                <option value="紧急">紧急</option>
	                          <%	}
		                            if(!"重要".equals(queryLevel)){%>
	                                <option value="重要">重要</option>
	                          <%	}
		                            if(!"普通".equals(queryLevel)){%>
	                                <option value="普通">普通</option>
	                          <%	}
		                        }%>
		                    </select>
		                </td>
		                
		                 <td class="td_title" title="报告人">报告人：</td>
		                <td class="td_title">
		                    <select id="reporter" name="reporter" style="width:100px;">
								<%	List<User> userList = (List<User>)request.getSession().getAttribute("userList");
									String queryReporter = (String)request.getAttribute("queryProjectTechNoteReporter");
									User queryReporterUser = (User)request.getAttribute("queryProjectTechNoteReporterUser");
									if("所有".equals(queryReporter) || queryReporter == null){%>
									<option title="所有" selected value="所有">所有</option>
								<%		for(User u : userList){ %>
										<option value="<%=u.getUsername()%>"><%=u.getRealName()%></option>
								<%		}
									}else{ %>
									<option title="所有" selected value="所有">所有</option>
								<%		for(User u : userList){
											if(queryReporterUser.getUsername().equals(u.getUsername())){%>
											<option selected value="<%=queryReporterUser.getUsername()%>"><%=queryReporterUser.getRealName()%></option>
								<%			}else{%>
									<option value="<%=u.getUsername()%>"><%=u.getRealName()%></option>
								<%			}
										}
									}	%>
		                    </select>
		                </td>
		                 <td class="td_title" title="处理人">处理人：</td>
		                <td class="td_title">
		                    <select id="doer" name="doer" style="width:100px;">
								<%	List<User> userLists = (List<User>)request.getSession().getAttribute("userList");
									String queryDoer = (String)request.getAttribute("queryProjectTechNoteDoer");
									User queryDoerUser = (User)request.getAttribute("queryProjectTechNoteDoerUser");
									if("所有".equals(queryDoer) || queryDoer == null){%>
									<option title="所有" selected value="所有">所有</option>
								<%		for(User u : userLists){ %>
										<option value="<%=u.getUsername()%>"><%=u.getRealName()%></option>
								<%		}
									}else{ %>
									<option title="所有" selected value="所有">所有</option>
								<%		for(User u : userLists){
											if(queryDoerUser.getUsername().equals(u.getUsername())){%>
											<option selected value="<%=queryDoerUser.getUsername()%>"><%=queryDoerUser.getRealName()%></option>
								<%			}else{%>
									<option value="<%=u.getUsername()%>"><%=u.getRealName()%></option>
								<%			}
										}
									}	%>
		                    </select>
		                </td>
		                <td title="时间">时间：</td>
		                <td>
							<%
						        Date date = new Date();
							    SimpleDateFormat sdFormat = new SimpleDateFormat("yyyy-MM-dd");
							    String endString = sdFormat.format(date);
							    Calendar calendar = Calendar.getInstance();
							    calendar.setTime(date);
							    calendar.add(Calendar.DATE,-7);
							    Date date2 = calendar.getTime();
							    String startString = sdFormat.format(date2);
							    String dayStart = (String)request.getAttribute("queryProjectTechNoteBegintime");
							    String dayEnd = (String)request.getAttribute("queryProjectTechNoteEndtime");
							    if(dayStart != null){
							         startString = dayStart;
							    }
							    if(dayEnd != null){
							         if(endString.equals(dayEnd)){
							             endString = "现在";
							         }else{
							              endString = dayEnd;
							         }
							    }else{
							        endString = "现在";
							    }
							 %>
							<input id="begintime" name="begintime" type="text" style="width:80px" onclick="MyCalendar.SetDate(this)" value="<%=startString %>" readonly="readonly" />
							</td>
							<td title="到">到</td>
							<td><input id="endtime" name="endtime" type="text" style="width:80px" onclick="MyCalendar.SetDate(this)" value="<%=endString %>" readonly="readonly" /></td>
							
		                	<td>
		                		<input type="hidden" name="id" value="<%=id%>"/>
								<div id="lastStateDiv"  style="color:red" >最新状态&nbsp;&nbsp;</div>
								<div id="sortDiv" style="display:none;width:280px;height:45px;border-style:solid;border-width:1px;border-color: #4A95BA" >
									<input type="checkbox" checked name="state" value="新增问题"/>新增问题
									<input type="checkbox" checked name="state" value="未安排计划"/>未安排计划
									<input type="checkbox" checked name="state" value="开发完成未上线"/>开发完成未上线<br/>
									<input type="checkbox" name="state" value="开发完成已经上线"/>开发完成已经上线
									<input type="checkbox" name="state" value="已经完成"/>已经完成
									<input type="checkbox" name="state" value="取消跟踪"/>取消跟踪
								</div>
							</td>
							<script type="text/javascript">
								
								var jq=jQuery.noConflict();
								jq("#lastStateDiv").mousemove(function(){
									jq("#sortDiv").slideDown("slow").mouseleave(function(){
										jq(this).slideUp();
									});
								});
							</script>
			                <td><input type="submit" value="查询" title="查询"/></td>
		           </tr>
		        </table>
		    </form>
		</div>
   		<div id="show_project_techNote" style="width:100%;height:95%; overflow-y:scroll; border:1px solid;" >
			<table id="dArticleList" width="100%" border="0" cellpadding="0" cellspacing="1"  class="resizable overTd">
				<thead>
					<tr class="fixHead">
						<td  class="td1" style="cursor:pointer" width="10%">所属项目名称</td>
						<td  class="td1" style="cursor:pointer" width="10%">报告日期</td>
						<td  class="td1" style="cursor:pointer" width="7%">报告人</td>
						<td  class="td1" style="cursor:pointer" width="18%">简述</td>
						<td  class="td1" style="cursor:pointer" width="10%">类型</td>
						<td  class="td1" style="cursor:pointer" width="5%">修复人</td>
						<td  class="td1" style="cursor:pointer" width="6%">级别</td>
						<td  class="td1" style="cursor:pointer" width="8%">最新状态</td>
						<td  class="td1" style="cursor:pointer" width="15%">技术说明</td>
						<td  class="td1" style="cursor:pointer"  width="6%">预计完成时间</td>
						<td  class="td1"  width="5%">操作</td>
					</tr>
				</thead>
				<tbody>
					<%
						List<TechNote> list = new ArrayList<TechNote>();
						List<TechNote> techNoteList = (List<TechNote>)request.getAttribute("projectTNList");
						if(techNoteList == null){
							list = (List<TechNote>)request.getSession().getAttribute("projectTechNoteList");
						} else {
							list = techNoteList;
						}
						for(TechNote t : list){
						%>
						<tr onMouseOver= "this.bgColor   =   '#cccccc '; "   onMouseOut= "this.bgColor   =   '#FFFFFF'; " >  
				       		<td title="<%=t.getProject().getProjectName() %>" align="center" class="td2 txbtip" ><%=t.getProject().getProjectName() %></td>
				       		<td title="<%=t.getReportDate() %>" align="center" class="td2 txbtip" ><%=t.getReportDate() %></td>
				       		<td title="<%=t.getReporter() %>" align="center" class="td2 txbtip" ><%=t.getReporter() %></td>
				       		<td title="<%=t.getDetailDesc() %>" align="center" class="td2 txbtip" ><%=t.getBriefDesc() %></td>
				       		<td title="<%=t.getType() %>" align="center" class="td2 txbtip" ><%=t.getType() %></td>
				       		<td title="<%=t.getDoer() %>" align="center" class="td2 txbtip" ><%=t.getDoer() %></td>
				       		<td title="<%=t.getLevel() %>" style="cursor:hand;" ondblclick="edit_project_techNote_stl(<%=t.getId()%>)" align="center" class="td2 txbtip" ><%=t.getLevel() %></td>
				       		<td title="<%=t.getState() %>" style="cursor:hand;" ondblclick="edit_project_techNote_stl(<%=t.getId()%>)" align="center" class="td2 txbtip" ><%=t.getState() %></td>
				       		<td title="<%=t.getTechDemon() %>" style="cursor:hand;" ondblclick="edit_project_techNote_stl(<%=t.getId()%>)" align="center" class="td2 txbtip" ><%=t.getTechDemon() %></td>
				       		<td title="<%=t.getClosetime() %>" align="center" ondblclick="edit_project_techNote_stl(<%=t.getId()%>)" class="td2" ><%=t.getClosetime() %></td>
				       		<td title="" align="center" class="td2" >
				       			<a href="#" class='buttonlink txbtip' title='修改' onclick="editTechNotes(<%=t.getId()%>)"><img width='16' height='16' src='${pageContext.request.contextPath}/images/common/edit.png'/></a>
				       			<img width='16' height='16' src='${pageContext.request.contextPath}/images/common/elbow-line.gif'/>
				       			<a href="#" class='buttonlink txbtip' title='删除' onclick="delTechNote('<%=t.getId()%>','你确定要删除？')" ><img width='16' height='16' src='${pageContext.request.contextPath}/images/common/delete.png'/></a>
				       		</td>
						</tr>	
					  <%}%>	
				</tbody>
				
			</table>
		</div>
	
   
   	<script type="text/javascript">
   		
   		//刷新操作
   		function refreshTechNote(){
   			document.getElementById("queryProjectTechNoteByCondition").submit();
   		};
   	
   		//编辑技术备忘录
   		function editTechNotes(tid){
   			AjaxUtil.request({
				url : 'select_TechNote_stl.action',
				params : {id:tid},
				success : function(responseText){
   					PigossMsg.show("${pageContext.request.contextPath}/jsp/techNote/editTechNote.jsp","编辑技术备忘录",530,510,"AddProjectTechNote.update_techNote("+tid+")");
				},
				failure : function(){
					PigossMsg.alert("修改失败!");
				}
			});
   		};
   		
   		
   		//删除技术备忘录
   		function delTechNote(tid){
			PigossMsg.confirm("您确定要删除这条技术备忘录吗？",null,function yesHandler(){AddProjectTechNote.del(tid)},function noHandler(){});
   		};
   	
   	
   		//编辑项目下的技术备忘录的常用状态
   		function edit_project_techNote_stl(id){
   			AjaxUtil.request({
				url : 'select_TechNote_stl.action',
				params : {id:id},
				success : function(responseText){
   					PigossMsg.show("${pageContext.request.contextPath}/jsp/techNote/editTechNoteState.jsp","编辑技术备忘录",320,360,"saveProjectTechNoteState("+id+")");
				},
				failure : function(){
					PigossMsg.alert("修改失败!");
				}
			});
   			
   		};
   		//更新记录
   		function saveProjectTechNoteState(id){
   			var editTechNoteLevel = document.getElementById("editTechNoteLevel").value;
			var editTechNoteState = document.getElementById("editTechNoteState").value;
			var editTechDemon = document.getElementById("editTechDemon").value;
			var editTechCloseDate = document.getElementById("editTechCloseDate").value;
			
			AjaxUtil.request({
				url : 'edit_TechNote_State.action',
				params : {editTechNoteStateid:id,editTechNoteState:editTechNoteState,editTechNoteLevel:editTechNoteLevel,editTechDemon:editTechDemon,editTechCloseDate:editTechCloseDate},
				success : function(responseText){
					document.getElementById("queryProjectTechNoteByCondition").submit();
				},
				failure : function(){
					PigossMsg.alert("修改失败!");
				}
			});
			imgCloseShow();
   		}
   		
   	
  		//切换项目下的服务信息表
		function lookSale(id){
			//window.parent.document.getElementById("mainFrame").src="${pageContext.request.contextPath}/jsp/project/project_id.jsp?id="+id;
			AjaxUtil.request({
				url : 'selectProject.action',
				params : {id:id},
				success : function(responseText){
					window.parent.document.getElementById("mainFrame").src="${pageContext.request.contextPath}/jsp/project/project_id.jsp?id="+id;
				},
				failure : function(){
				}
			});
  		};
   		
   		//切换项目下的客户信息表
   		function lookClient(projectClientId){
   			//window.parent.document.getElementById("mainFrame").src="${pageContext.request.contextPath}/jsp/project/project_clients.jsp?id="+id;
   			AjaxUtil.request({
				url : 'look_project_client.action',
				params : {projectClientId:projectClientId},
				success : function(responseText){
   					window.parent.document.getElementById("mainFrame").src="${pageContext.request.contextPath}/jsp/project/project_clients.jsp?id="+projectClientId;
				},
				failure : function(){
				}
			});
   		};
   		
   		//切换项目下的文档列表
   		function lookDoc(id){
   			AjaxUtil.request({
				url : 'look_project_doc.action',
				params : {id:id},
				success : function(responseText){
   					window.parent.document.getElementById("mainFrame").src="${pageContext.request.contextPath}/jsp/project/project_doc.jsp?id="+id;
				},
				failure : function(){
				}
			});
   		};
   		
   		//添加技术备忘录
   		function addTechNote(id){
   			PigossMsg.show("${pageContext.request.contextPath}/jsp/project/addTechNote.jsp?id="+id,"添加项目下的技术备忘录",470,420,"AddProjectTechNote.saveTechNote()");
   		};
   		
   		//点击查询技术备忘录
   		function selectTechNote(id){
   			AjaxUtil.request({
				url : 'selectTechNote.action',
				params : {id:id},
				success : function(responseText){
					window.document.getElementById("changePage").src="${pageContext.request.contextPath}/jsp/project/project_techNote.jsp?id="+id;
				},
				failure : function(){
					PigossMsg.alert("查询技术备忘录失败！");
				}
			});
   		};
   		
   		
   		
   		//切换查询条件
   		function notHiddenDiv(){
	        var idDiv = document.getElementById('projectService');
	        if(idDiv.style.display=='none'){
	            idDiv.style.display='block'; 
	        }else{
	           idDiv.style.display='none'; 
	        };
	    };
	    
	    initTableWidget('dArticleList',['S','S',"S",'S','S','S','S','S','S','S',false]);
   	
	</script>
   
   
  </body>
	</body>
</html>
    
    
    
